/*
ID: edestef1
TASK: buylow
LANG: C++
*/
#include <cstdio>
#include <sstream>
#include <fstream>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>

using namespace std;

string sum(string a, string b) {
  string res(max(a.size(), b.size()), '0');
  //cout << "SUM " << a << " " << b << " " ;
  int carry = 0, i;
  for (i = 0; i < max(a.size(), b.size()); ++i) {
    int d1= 0, d2 = 0;
    if (i < a.size()) d1 = a[i]-'0';
    if (i < b.size()) d2 = b[i]-'0';
    d1 += carry + d2;
    res[i] = '0' + (d1 % 10);
    carry = d1/10;
  }
  if (carry) res = res+"0";
  res[i] = carry + '0';
  //cout << res << endl;
  return res;
}


int main() {
  int i,j ,k;
  int N;
  ifstream input("buylow.in");
  input >> N;
  int arr[5001];
  for (i = 0; i < N; ++i) input >> arr[i];
  int dp[5001];
  string dpcant[5001];
  for (i = 0; i < N; ++i) dp[i] = 1, dpcant[i] = "1";
  int res = 1;
  string cant = "0";
  for (i = 0; i < N; ++i) for (j = i + 1; j < N; ++j) {
    if (arr[i] == arr[j]) break;
    if (arr[i] > arr[j]) {
      if (dp[i]+1 > dp[j]) {
        dp[j] = dp[i] + 1;
        dpcant[j] = dpcant[i];
        if (dp[j] > res) {
          res = dp[j];
        }
      } else if (dp[i]+1 == dp[j]) {
        dpcant[j] = sum(dpcant[j], dpcant[i]);
      }
    }
  } 
  //cout << res << endl;
  map<int, bool> seen;
  for (i = N-1; i>=0; --i) if (dp[i] == res) {
    if (seen[arr[i]]) continue;
    seen[arr[i]] = true;
    //cout << dpcant[i] << endl;
    cant = sum(cant,dpcant[i]);
  }
  reverse(cant.begin(), cant.end());
  ofstream output("buylow.out");
  output << res << " " << cant << endl;
  return 0;
}
